﻿using Dyao.Book.Entity;
using System.Linq.Expressions;

namespace Dyao.Book.Repository.Abstractions
{
    public interface IBookRepository : IDataRepository<BookEntity>
    {
        /// <summary>
        /// 批量更新
        /// </summary>
        /// <param name="entities">实体</param>
        /// <param name="updateSelector">选择器</param>
        /// <param name="cancellationToken">取消令牌</param>
        /// <returns></returns>
        Task BulkUpdateAsync(IEnumerable<BookEntity> entities, Expression<Func<BookEntity, object>> updateSelector, CancellationToken cancellationToken = default);

        /// <summary>
        /// 根据标题获取书籍信息
        /// </summary>
        /// <param name="titles">书籍标题</param>
        /// <param name="cancellationToken">取消令牌</param>
        /// <returns></returns>
        Task<List<BookEntity>> GetListByTitleAsync(List<string> titles, CancellationToken cancellationToken);

        /// <summary>
        /// 根据Id获取书籍列表
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="ids">编号</param>
        /// <param name="selector">选择器</param>
        /// <param name="cancellationToken">取消令牌</param>
        /// <returns></returns>
        Task<List<T>> GetListByIdsAsync<T>(List<string> ids, Expression<Func<BookEntity, T>> selector, CancellationToken cancellationToken);

        /// <summary>
        /// 根据Id获取实体
        /// </summary>
        /// <param name="id">编号</param>
        /// <param name="cancellationToken">取消令牌</param>
        /// <returns></returns>
        Task<BookEntity> GetByIdAsync(string id, CancellationToken cancellationToken);

        /// <summary>
        /// 获取所有数据
        /// </summary>
        /// <typeparam name="T">指定字段</typeparam>
        /// <param name="selector">选择器</param>
        /// <param name="cancellationToken">取消令牌</param>
        /// <returns></returns>
        Task<List<T>> GetAllListAsync<T>(Expression<Func<BookEntity, T>> selector, CancellationToken cancellation);
    }
}
